﻿using System.ComponentModel;
using System.Diagnostics.Contracts;
using GIMS.Def.Interfaces;

namespace GIMS.Def.Arguments
{
    public abstract class Argument : IScriptPart, INotifyPropertyChanged
    {
        protected string name;
        protected Flags.ArgumentType type=Flags.ArgumentType.none;
        public event PropertyChangedEventHandler PropertyChanged;

        public abstract string CreateScriptPart();

        public string Name
        {
            get
            {
                Contract.Ensures(!string.IsNullOrEmpty(name),"Argument name is not set");
                return name;
            }
        }

        public Flags.ArgumentType Type
        {
            get
            {
                Contract.Ensures(type!=Flags.ArgumentType.none);
                return type;
            }
        }

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
